<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.3.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"example.com","root":"/","scheme":"Muse","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"search.json"};
  </script>

  <meta name="description" content="搬砖 嵌入式">
<meta property="og:type" content="website">
<meta property="og:title" content="学无止境">
<meta property="og:url" content="http://example.com/page/19/index.html">
<meta property="og:site_name" content="学无止境">
<meta property="og:description" content="搬砖 嵌入式">
<meta property="og:locale" content="zh_CN">
<meta property="article:author" content="xudonglei">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="http://example.com/page/19/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : true,
    isPost : false,
    lang   : 'zh-CN'
  };
</script>

  <title>学无止境</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">学无止境</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">Do not bb, show me the example</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-fw fa-home"></i>首页</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-fw fa-tags"></i>标签</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-fw fa-th"></i>分类</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-fw fa-archive"></i>归档</a>

  </li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup">
        <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result">
  <div id="no-result">
    <i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>
  </div>
</div>

    </div>
  </div>

</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content index posts-expand">
            
      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2022/01/09/opengl%E4%B8%ADglClear/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2022/01/09/opengl%E4%B8%ADglClear/" class="post-title-link" itemprop="url">opengl中glClear</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2022-01-09 13:57:13" itemprop="dateCreated datePublished" datetime="2022-01-09T13:57:13+08:00">2022-01-09</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/python/" itemprop="url" rel="index"><span itemprop="name">python</span></a>
                </span>
            </span>

          
            <span id="/2022/01/09/opengl%E4%B8%ADglClear/" class="post-meta-item leancloud_visitors" data-flag-title="opengl中glClear" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2022/01/09/opengl%E4%B8%ADglClear/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2022/01/09/opengl%E4%B8%ADglClear/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​        部分参考文章原文地址：<a target="_blank" rel="noopener" href="https://developer.aliyun.com/article/258453">https://developer.aliyun.com/article/258453</a></p>
<p><strong>函数原型:</strong></p>
<p>   void glClear(GLbitfield mask);</p>
<p><strong>参数说明：</strong></p>
<p>   GLbitfield：可以使用 | 运算符组合不同的缓冲标志位，表明需要清除的缓冲，例如glClear（GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT）表示要清除颜色缓冲以及深度缓冲，可以使用以下标志位</p>
<ul>
<li>   GL_COLOR_BUFFER_BIT:  当前可写的颜色缓冲</li>
<li>   GL_DEPTH_BUFFER_BIT:  深度缓冲</li>
<li>   GL_ACCUM_BUFFER_BIT:  累积缓冲</li>
<li>   GL_STENCIL_BUFFER_BIT: 模板缓冲</li>
</ul>
<p><strong>函数说明：</strong></p>
<pre><code>   glClear（）函数的作用是用当前缓冲区清除值，也就是glClearColor或者glClearDepth、glClearIndex、glClearStencil、glClearAccum等函数所指定的值来清除指定的缓冲区，也可以使用glDrawBuffer一次清除多个颜色缓存。比如：</code></pre>
<p>　　glClearColor（0.0，0.0，0.0，0.0）;</p>
<p>　　glClear（GL_COLOR_BUFFER_BIT）;</p>
<p>　　第一条语句表示清除颜色设为黑色，第二条语句表示实际完成了把整个窗口清除为黑色的任务，glClear（）的唯一参数表示需要被清除的缓冲区。</p>
<p><strong>实例</strong></p>
<p>​        下面看两个例子，分别是使用glClear和不使用glClear产生的效果。</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> pygame</span><br><span class="line"><span class="keyword">from</span> pygame.<span class="built_in">locals</span> <span class="keyword">import</span> *</span><br><span class="line"><span class="keyword">from</span> OpenGL.GL <span class="keyword">import</span> *</span><br><span class="line"><span class="keyword">from</span> OpenGL.GLU <span class="keyword">import</span> *</span><br><span class="line">verticies = (</span><br><span class="line">    (<span class="number">1</span>, -<span class="number">1</span>, -<span class="number">1</span>),</span><br><span class="line">    (<span class="number">1</span>, <span class="number">1</span>, -<span class="number">1</span>),</span><br><span class="line">    (-<span class="number">1</span>, <span class="number">1</span>, -<span class="number">1</span>),</span><br><span class="line">    (-<span class="number">1</span>, -<span class="number">1</span>, -<span class="number">1</span>),</span><br><span class="line">    (<span class="number">1</span>, -<span class="number">1</span>, <span class="number">1</span>),</span><br><span class="line">    (<span class="number">1</span>, <span class="number">1</span>, <span class="number">1</span>),</span><br><span class="line">    (-<span class="number">1</span>, -<span class="number">1</span>, <span class="number">1</span>),</span><br><span class="line">    (-<span class="number">1</span>, <span class="number">1</span>, <span class="number">1</span>)</span><br><span class="line">    )</span><br><span class="line">edges = (</span><br><span class="line">    (<span class="number">0</span>,<span class="number">1</span>),</span><br><span class="line">    (<span class="number">0</span>,<span class="number">3</span>),</span><br><span class="line">    (<span class="number">0</span>,<span class="number">4</span>),</span><br><span class="line">    (<span class="number">2</span>,<span class="number">1</span>),</span><br><span class="line">    (<span class="number">2</span>,<span class="number">3</span>),</span><br><span class="line">    (<span class="number">2</span>,<span class="number">7</span>),</span><br><span class="line">    (<span class="number">6</span>,<span class="number">3</span>),</span><br><span class="line">    (<span class="number">6</span>,<span class="number">4</span>),</span><br><span class="line">    (<span class="number">6</span>,<span class="number">7</span>),</span><br><span class="line">    (<span class="number">5</span>,<span class="number">1</span>),</span><br><span class="line">    (<span class="number">5</span>,<span class="number">4</span>),</span><br><span class="line">    (<span class="number">5</span>,<span class="number">7</span>)</span><br><span class="line">    )</span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">Cube</span>():</span></span><br><span class="line">    glBegin(GL_LINES)</span><br><span class="line">    <span class="keyword">for</span> edge <span class="keyword">in</span> edges:</span><br><span class="line">        <span class="keyword">for</span> vertex <span class="keyword">in</span> edge:</span><br><span class="line">            glVertex3fv(verticies[vertex])</span><br><span class="line">    glEnd()</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">main</span>():</span></span><br><span class="line">    pygame.init()</span><br><span class="line">    display = (<span class="number">640</span>, <span class="number">480</span>)</span><br><span class="line">    pygame.display.set_mode(display, DOUBLEBUF | OPENGL)</span><br><span class="line"></span><br><span class="line">    gluPerspective(<span class="number">45</span>, (display[<span class="number">0</span>]/display[<span class="number">1</span>]), <span class="number">0.1</span>, <span class="number">50.0</span>)</span><br><span class="line">    glTranslatef(<span class="number">0</span>, <span class="number">0</span>, -<span class="number">5</span>)</span><br><span class="line"></span><br><span class="line">    <span class="keyword">while</span> <span class="literal">True</span>:</span><br><span class="line">        glTranslatef(<span class="number">0.001</span>, <span class="number">0</span>, <span class="number">0</span>)</span><br><span class="line">        <span class="comment"># glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)</span></span><br><span class="line">        Cube()</span><br><span class="line">        pygame.display.flip()</span><br><span class="line">        pygame.time.wait(<span class="number">2</span>)</span><br><span class="line">main()</span><br></pre></td></tr></table></figure>
<p><strong>效果：</strong></p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202201091427484.gif" style="zoom:50%;">

<p>如果将glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)代码加上，效果就正常了，如下所示：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202201091429734.gif" style="zoom:57%;">


      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2022/01/09/opengl%E4%B8%AD%E7%9A%84%E9%A2%9C%E8%89%B2%E7%BC%93%E5%86%B2%E5%8C%BA%E5%92%8C%E6%B7%B1%E5%BA%A6%E7%BC%93%E5%86%B2%E5%8C%BA/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2022/01/09/opengl%E4%B8%AD%E7%9A%84%E9%A2%9C%E8%89%B2%E7%BC%93%E5%86%B2%E5%8C%BA%E5%92%8C%E6%B7%B1%E5%BA%A6%E7%BC%93%E5%86%B2%E5%8C%BA/" class="post-title-link" itemprop="url">opengl中的颜色缓冲区和深度缓冲区</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2022-01-09 13:40:48" itemprop="dateCreated datePublished" datetime="2022-01-09T13:40:48+08:00">2022-01-09</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/python/" itemprop="url" rel="index"><span itemprop="name">python</span></a>
                </span>
            </span>

          
            <span id="/2022/01/09/opengl%E4%B8%AD%E7%9A%84%E9%A2%9C%E8%89%B2%E7%BC%93%E5%86%B2%E5%8C%BA%E5%92%8C%E6%B7%B1%E5%BA%A6%E7%BC%93%E5%86%B2%E5%8C%BA/" class="post-meta-item leancloud_visitors" data-flag-title="opengl中的颜色缓冲区和深度缓冲区" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2022/01/09/opengl%E4%B8%AD%E7%9A%84%E9%A2%9C%E8%89%B2%E7%BC%93%E5%86%B2%E5%8C%BA%E5%92%8C%E6%B7%B1%E5%BA%A6%E7%BC%93%E5%86%B2%E5%8C%BA/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2022/01/09/opengl%E4%B8%AD%E7%9A%84%E9%A2%9C%E8%89%B2%E7%BC%93%E5%86%B2%E5%8C%BA%E5%92%8C%E6%B7%B1%E5%BA%A6%E7%BC%93%E5%86%B2%E5%8C%BA/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​        部分参考文章原文地址：<a target="_blank" rel="noopener" href="https://blog.csdn.net/u012861978/article/details/93540146">https://blog.csdn.net/u012861978/article/details/93540146</a></p>
<p>​                                                <a target="_blank" rel="noopener" href="https://blog.csdn.net/u014587123/article/details/80334715">https://blog.csdn.net/u014587123/article/details/80334715</a></p>
<p><strong>颜色缓冲区</strong></p>
<p>​        颜色缓冲区（COLOR_BUFFER）就是帧缓冲区（FRAME_BUFFER）,你需要渲染的场景最终每一个像素都要写入该缓冲区,然后由它在渲染到屏幕上显示.</p>
<p><strong>深度缓冲区</strong></p>
<p>​        深度缓冲区（DEPTH_BUFFER）与帧缓冲区对应,用于记录上面每个像素的深度值,通过深度缓冲区,我们可以进行深度测试,从而确定像素的遮挡关系,保证渲染正确.</p>
<p><strong>何为深度</strong></p>
<p>​        深度其实就是该象素点在3d世界中距离摄象机的距离（绘制坐标），深度缓存中存储着每个象素点（绘制在屏幕上的）的深度值！深度值（Z值）越大，则离摄像机越远。</p>
<p><strong>为什么需要深度</strong></p>
<p>​        在不使用深度测试的时候，如果我们先绘制一个距离较近的物体，再绘制距离较远的物体，则距离远的物体因为后绘制，会把距离近的物体覆盖掉，这样的效果并不是我们所希望的。而有了深度缓冲以后，绘制物体的顺序就不那么重要了，都能按照远近（Z值）正常显示，这很关键。</p>
<p><strong>深度缓冲原理</strong></p>
<p>​        深度缓冲区原理就是把一个距离观察平面(近裁剪面)的深度值(或距离)与窗口中的每个像素相关联。首先，使用glClear(GL_DEPTH_BUFFER_BIT),把所有像素的深度值设置为最大值(一般是远裁剪面)。然后，在场景中以任意次序绘制所有物体。硬件或者软件所执行的图形计算把每一个绘制表面转换为窗口上一些像素的集合，此时并不考虑是否被其他物体遮挡。其次，OpenGL会计算这些表面和观察平面的距离。如果启用了深度缓冲区，在绘制每个像素之前，OpenGL会把它的深度值和已经存储在这个像素的深度值进行比较。新像素深度值&lt;原先像素深度值，则新像素值会取代原先的；反之，新像素值被遮挡，他颜色值和深度将被丢弃。为了启动深度缓冲区，必须先启动它，即glEnable(GL_DEPTH_TEST)。每次绘制场景之前，需要先清除深度缓冲区，即glClear(GL_DEPTH_BUFFER_BIT)，然后以任意次序绘制场景中的物体。<br><strong>深度测试：</strong></p>
<p>​        在默认情况是将需要绘制的新像素的z值与深度缓冲区中对应位置的z值进行比较，如果比深度缓存中的值小，那么用新像素的颜色值更新帧缓存中对应像素的颜色值。但是可以使用glDepthFunc(func)来对这种默认测试方式进行修改。其中参数func的值可以为GL_NEVER（没有处理）、GL_ALWAYS（处理所有）、GL_LESS（小于）、GL_LEQUAL（小于等于）、GL_EQUAL（等于）、GL_GEQUAL（大于等于）、GL_GREATER（大于）或GL_NOTEQUAL（不等于），其中默认值是GL_LESS。<br>​        一般来将，使用glDepthFunc(GL_LEQUAL);来表达一般物体之间的遮挡关系。</p>
<p><strong>弊端：</strong></p>
<p>​        启用了深度测试，那么这就不适用于同时绘制不透明物体。当需要绘制半透明物体时，需注意，在绘制半透明物体时前，还需要利用glDepthMask(GL_FALSE)将深度缓冲区设置为只读形式，否则可能出现画面错误。为什么呢，因为画透明物体时，将使用混色，这时就不能继续使用深度模式，而是利用混色函数来进行混合。这一来，就可以使用混合函数绘制半透明物体了。</p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2022/01/09/opengl%E4%B8%AD%E7%9A%84glTranslatef/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2022/01/09/opengl%E4%B8%AD%E7%9A%84glTranslatef/" class="post-title-link" itemprop="url">opengl中的glTranslatef</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2022-01-09 12:19:03" itemprop="dateCreated datePublished" datetime="2022-01-09T12:19:03+08:00">2022-01-09</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/python/" itemprop="url" rel="index"><span itemprop="name">python</span></a>
                </span>
            </span>

          
            <span id="/2022/01/09/opengl%E4%B8%AD%E7%9A%84glTranslatef/" class="post-meta-item leancloud_visitors" data-flag-title="opengl中的glTranslatef" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2022/01/09/opengl%E4%B8%AD%E7%9A%84glTranslatef/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2022/01/09/opengl%E4%B8%AD%E7%9A%84glTranslatef/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​        部分参考文章原文地址：<a target="_blank" rel="noopener" href="https://www.i4k.xyz/article/weixin_34008784/94602078">https://www.i4k.xyz/article/weixin_34008784/94602078</a></p>
<h3 id="坐标系"><a href="#坐标系" class="headerlink" title="坐标系"></a>坐标系</h3><p>​        OPENGL坐标系可分为：世界坐标系和当前绘图坐标系。</p>
<p><strong>世界坐标系</strong>：</p>
<p>​        在OpenGL中，世界坐标系是以屏幕中心为原点(0, 0, 0)，且是始终不变的。你面对屏幕，你的右边是x正轴，上面是y正轴，屏幕指向你的为z正轴。长度单位这样来定：窗口范围按此单位恰好是(-1,-1)到(1,1)，即屏幕左下角坐标为（-1，-1），右上角坐标为（1,1）。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202201091242046.png" style="zoom:47%;">

<p><strong>当前绘图坐标系</strong>：</p>
<p>​        是绘制物体时的坐标系。程序刚初始化时，世界坐标系和当前绘图坐标系是重合的。当用glTranslatef()，glScalef(), glRotatef()等对当前绘图坐标系进行平移、伸缩、旋转变换之后，世界坐标系和当前绘图坐标系不再重合。<strong>注意，这里的平移旋转是将当前绘图坐标系看做一个整体在世界坐标系中进行旋转平移。</strong>然后，改变以后，再用glVertex3f()等绘图函数绘图时，都是在当前绘图坐标系进行绘图，所有的函数参数也都是相对当前绘图坐标系来讲的。</p>
<h3 id="实例"><a href="#实例" class="headerlink" title="实例:"></a>实例:</h3><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> pygame</span><br><span class="line"><span class="keyword">from</span> pygame.<span class="built_in">locals</span> <span class="keyword">import</span> *</span><br><span class="line"><span class="keyword">from</span> OpenGL.GL <span class="keyword">import</span> *</span><br><span class="line"><span class="keyword">from</span> OpenGL.GLU <span class="keyword">import</span> *</span><br><span class="line"></span><br><span class="line">verticies = (</span><br><span class="line">    (<span class="number">1</span>, -<span class="number">1</span>, -<span class="number">1</span>),</span><br><span class="line">    (<span class="number">1</span>, <span class="number">1</span>, -<span class="number">1</span>),</span><br><span class="line">    (-<span class="number">1</span>, <span class="number">1</span>, -<span class="number">1</span>),</span><br><span class="line">    (-<span class="number">1</span>, -<span class="number">1</span>, -<span class="number">1</span>),</span><br><span class="line">    (<span class="number">1</span>, -<span class="number">1</span>, <span class="number">1</span>),</span><br><span class="line">    (<span class="number">1</span>, <span class="number">1</span>, <span class="number">1</span>),</span><br><span class="line">    (-<span class="number">1</span>, -<span class="number">1</span>, <span class="number">1</span>),</span><br><span class="line">    (-<span class="number">1</span>, <span class="number">1</span>, <span class="number">1</span>)</span><br><span class="line">    )</span><br><span class="line">edges = (</span><br><span class="line">    (<span class="number">0</span>,<span class="number">1</span>),</span><br><span class="line">    (<span class="number">0</span>,<span class="number">3</span>),</span><br><span class="line">    (<span class="number">0</span>,<span class="number">4</span>),</span><br><span class="line">    (<span class="number">2</span>,<span class="number">1</span>),</span><br><span class="line">    (<span class="number">2</span>,<span class="number">3</span>),</span><br><span class="line">    (<span class="number">2</span>,<span class="number">7</span>),</span><br><span class="line">    (<span class="number">6</span>,<span class="number">3</span>),</span><br><span class="line">    (<span class="number">6</span>,<span class="number">4</span>),</span><br><span class="line">    (<span class="number">6</span>,<span class="number">7</span>),</span><br><span class="line">    (<span class="number">5</span>,<span class="number">1</span>),</span><br><span class="line">    (<span class="number">5</span>,<span class="number">4</span>),</span><br><span class="line">    (<span class="number">5</span>,<span class="number">7</span>)</span><br><span class="line">    )</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">Cube</span>():</span></span><br><span class="line">    glBegin(GL_LINES)</span><br><span class="line">    <span class="keyword">for</span> edge <span class="keyword">in</span> edges:</span><br><span class="line">        <span class="keyword">for</span> vertex <span class="keyword">in</span> edge:</span><br><span class="line">            glVertex3fv(verticies[vertex])</span><br><span class="line">    glEnd()</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">main</span>():</span></span><br><span class="line">    pygame.init()</span><br><span class="line">    display = (<span class="number">640</span>, <span class="number">480</span>)</span><br><span class="line">    pygame.display.set_mode(display, DOUBLEBUF | OPENGL)</span><br><span class="line"></span><br><span class="line">    gluPerspective(<span class="number">45</span>, (display[<span class="number">0</span>]/display[<span class="number">1</span>]), <span class="number">0.1</span>, <span class="number">50.0</span>)</span><br><span class="line">    glTranslatef(<span class="number">0.5</span>, -<span class="number">0.5</span>, -<span class="number">5</span>)</span><br><span class="line"></span><br><span class="line">    <span class="keyword">while</span> <span class="literal">True</span>:</span><br><span class="line">        Cube()</span><br><span class="line">        pygame.display.flip()</span><br><span class="line">main()</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202201091251419.png" style="zoom:67%;">

<p>这个就是glTranslatef(0.5, -0.5, -5)带来的效果，另外Z轴的大小要设置合适，设置0或者正数有可能看不到。</p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2022/01/01/pygame%E5%85%A5%E9%97%A8%E5%B0%8F%E4%BE%8B%E5%AD%90/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2022/01/01/pygame%E5%85%A5%E9%97%A8%E5%B0%8F%E4%BE%8B%E5%AD%90/" class="post-title-link" itemprop="url">pygame入门小例子</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2022-01-01 18:14:30" itemprop="dateCreated datePublished" datetime="2022-01-01T18:14:30+08:00">2022-01-01</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/python/" itemprop="url" rel="index"><span itemprop="name">python</span></a>
                </span>
            </span>

          
            <span id="/2022/01/01/pygame%E5%85%A5%E9%97%A8%E5%B0%8F%E4%BE%8B%E5%AD%90/" class="post-meta-item leancloud_visitors" data-flag-title="pygame入门小例子" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2022/01/01/pygame%E5%85%A5%E9%97%A8%E5%B0%8F%E4%BE%8B%E5%AD%90/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2022/01/01/pygame%E5%85%A5%E9%97%A8%E5%B0%8F%E4%BE%8B%E5%AD%90/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​        今天是2022年的第一天，2021年总共整理了99篇博文，希望新的一年再接再厉。</p>
<p>​        下面的一些内容来自于网络博文，原文地址：<a target="_blank" rel="noopener" href="https://blog.csdn.net/zha6476003/article/details/82940350/">https://blog.csdn.net/zha6476003/article/details/82940350/</a></p>
<p><strong>安装方式：</strong></p>
<p>​        pip install -i <a target="_blank" rel="noopener" href="https://pypi.tuna.tsinghua.edu.cn/simple">https://pypi.tuna.tsinghua.edu.cn/simple</a> pygame</p>
<p><strong>例子：</strong></p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> pygame</span><br><span class="line"><span class="keyword">import</span> sys</span><br><span class="line"></span><br><span class="line">pygame.init()  <span class="comment"># 初始化pygame</span></span><br><span class="line">size = width, height = <span class="number">640</span>, <span class="number">480</span>  <span class="comment"># 设置窗口大小</span></span><br><span class="line">screen = pygame.display.set_mode(size)  <span class="comment"># 显示窗口</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">while</span> <span class="literal">True</span>:  <span class="comment"># 死循环确保窗口一直显示</span></span><br><span class="line">    <span class="keyword">for</span> event <span class="keyword">in</span> pygame.event.get():  <span class="comment"># 遍历所有事件</span></span><br><span class="line">        <span class="keyword">if</span> event.<span class="built_in">type</span> == pygame.KEYDOWN:  <span class="comment"># 如果键盘按下，则退出</span></span><br><span class="line">            sys.exit()</span><br><span class="line"></span><br><span class="line">pygame.quit()  <span class="comment"># 退出pygame</span></span><br></pre></td></tr></table></figure>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20211231183326.png" style="zoom:47%;">

<p>​        上述代码中，首先导入pygame模块，然后调用init()方法初始化pygame模块，接下来，设置窗口的宽和高，最后使用display模块显示窗体。pygame.display.set_mode():初始化一个准备显示的界面。</p>
<p>​        如果想要让窗口一直显示，需要使用while True让程序一直执行。</p>
<p>​        上述代码中添加了轮询事件检测。pygame.event.get()能够获取事件队列，使用for…in遍历事件，然后根据type属性判断事件类型。这里的事件处理方式与GUI类似，如event.type等于pygame.QUIT表示检测到关闭pygame窗口事件，pygame.KEYDOWN表示键盘按下事件，pygame.MOUSEBUTTONDOWN表示鼠标按下事件等。</p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2021/12/27/%E4%BF%A1%E5%8F%B7%E7%9A%84%E6%B7%B7%E5%8F%A0/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2021/12/27/%E4%BF%A1%E5%8F%B7%E7%9A%84%E6%B7%B7%E5%8F%A0/" class="post-title-link" itemprop="url">信号的混叠</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-12-27 09:32:12" itemprop="dateCreated datePublished" datetime="2021-12-27T09:32:12+08:00">2021-12-27</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E6%9D%82/" itemprop="url" rel="index"><span itemprop="name">杂</span></a>
                </span>
            </span>

          
            <span id="/2021/12/27/%E4%BF%A1%E5%8F%B7%E7%9A%84%E6%B7%B7%E5%8F%A0/" class="post-meta-item leancloud_visitors" data-flag-title="信号的混叠" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2021/12/27/%E4%BF%A1%E5%8F%B7%E7%9A%84%E6%B7%B7%E5%8F%A0/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2021/12/27/%E4%BF%A1%E5%8F%B7%E7%9A%84%E6%B7%B7%E5%8F%A0/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​        主要内容摘自于下面这篇博文：<a target="_blank" rel="noopener" href="https://blog.csdn.net/daduzimama/article/details/80263296">https://blog.csdn.net/daduzimama/article/details/80263296</a> ，对原作者表示感谢。</p>
<p><strong>混叠频率的计算</strong></p>
<p>​        现假设信号采样频率为100 Hz，输入信号包含下列频率：25 Hz、70 Hz、160 Hz和510 Hz。 低于50 Hz奈奎斯特频率才可正确采样，超过50 Hz的频率显示为混叠，所以只有频率为25Hz的信号才能被正确采样。fs/2为奈奎斯特频率即采样频率的一半。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20211227093623.png" style="zoom:70%;">

<p>​        其中，频率超过50Hz的信号的混叠频率计算公式为：</p>
<p>​        （1）当输入信号的频率F2为70Hz时，采样频率Fs为100Hz。按照奈奎斯特采样定律，要想对70Hz的输入信号充分采样，采样频率至少要大于140Hz，即输入信号频率的两倍。所以发生了混叠，由于输入频率为70，所以离采样频率100最近的整数倍数是1（即，这里的（closest integermultiple of fs） = 1）。  计算结果如下：<br>​            F2 Alias = |100 - 70| = 30Hz</p>
<p>​        （2）当输入信号的频率F3为160Hz时，采样频率为Fs100Hz。采样频率低于输入信号的频率，发生了混叠，由于输入频率为160，所以离采样频率100最近的整数倍数是2（即，这里的（closest integermultiple of fs） = 2）。  计算结果如下：<br>​            F3 Alias = |2*100 - 160| = 40Hz</p>
<p>​        （3）当输入信号的频率F4为510Hz时，采样频率为Fs100Hz。采样频率低于输入信号的频率，发生了混叠，由于输入频率为510，所以离采样频率100最近的整数倍数是5（即，这里的（closest integermultiple of fs） = 5）。  计算结果如下：<br>​            F4 Alias = |5*100 - 510| = 10Hz</p>
<p><strong>混叠频率即折叠频率</strong></p>
<p>​        混叠频率有时又叫折叠频率，只需把超过奈奎斯特频率（Fs/2）的频段或是超过采样频率（Fs）的频段以奈奎斯特频率或采样频率为中轴对折过去就好了。或者说是以奈奎斯特频率或采样频率为中轴的镜像。如下图，一个6Hz的信号以奈奎斯特频率3.5Hz为中轴折叠为1Hz的信号。同理，一个8Hz的信号以采样频率7Hz为中轴折叠为频率为6Hz的信号。<br><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20211227094951.png" style="zoom:80%;"></p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2021/12/16/%E5%88%A0%E6%8E%89printf%E5%BC%95%E5%8F%91%E7%9A%84HardFault/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2021/12/16/%E5%88%A0%E6%8E%89printf%E5%BC%95%E5%8F%91%E7%9A%84HardFault/" class="post-title-link" itemprop="url">删掉printf引发的HardFault</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-12-16 20:29:29" itemprop="dateCreated datePublished" datetime="2021-12-16T20:29:29+08:00">2021-12-16</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F/" itemprop="url" rel="index"><span itemprop="name">嵌入式</span></a>
                </span>
            </span>

          
            <span id="/2021/12/16/%E5%88%A0%E6%8E%89printf%E5%BC%95%E5%8F%91%E7%9A%84HardFault/" class="post-meta-item leancloud_visitors" data-flag-title="删掉printf引发的HardFault" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2021/12/16/%E5%88%A0%E6%8E%89printf%E5%BC%95%E5%8F%91%E7%9A%84HardFault/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2021/12/16/%E5%88%A0%E6%8E%89printf%E5%BC%95%E5%8F%91%E7%9A%84HardFault/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p><strong>问题</strong>：程序中有一个地方把printf删掉了，结果程序进入hardfault。</p>
<p><strong>解决：</strong></p>
<p>​        这个问题很奇怪，hardfault很少会是由printf产生的，多数都是踩到了不该踩的内存，或者数组越界啥的。后来查下来的结果也确实是数组越界引起的。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20211216203504.png" style="zoom:80%;">

<p>​        其中idx这个局部变量我一开始没有初始化，因为在程序的某个位置满足条件的时候会进行赋值，而刚巧某些时候这个条件不满足，就会使得idx不会进行赋值而变成一个随机值。</p>
<p>​        当不加printf的时候，这个局部变量idx的值非常随机，某个时候的一个随机值就会使得越界的数组hardfault。而当加上这个printf的时候，刚巧会使得idx这个局部变量的值是一个固定的随机值，而这个固定的随机值刚巧不会使得越界的数组发生hardfault。</p>
<p>​        真的是巧啊巧啊。。。</p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2021/11/22/FFT%E8%A1%A5%E9%9B%B6%E5%AF%B9%E6%97%81%E7%93%A3%E7%9A%84%E5%BD%B1%E5%93%8D/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2021/11/22/FFT%E8%A1%A5%E9%9B%B6%E5%AF%B9%E6%97%81%E7%93%A3%E7%9A%84%E5%BD%B1%E5%93%8D/" class="post-title-link" itemprop="url">FFT补零对旁瓣的影响</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-11-22 18:06:12" itemprop="dateCreated datePublished" datetime="2021-11-22T18:06:12+08:00">2021-11-22</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E6%9D%82/" itemprop="url" rel="index"><span itemprop="name">杂</span></a>
                </span>
            </span>

          
            <span id="/2021/11/22/FFT%E8%A1%A5%E9%9B%B6%E5%AF%B9%E6%97%81%E7%93%A3%E7%9A%84%E5%BD%B1%E5%93%8D/" class="post-meta-item leancloud_visitors" data-flag-title="FFT补零对旁瓣的影响" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2021/11/22/FFT%E8%A1%A5%E9%9B%B6%E5%AF%B9%E6%97%81%E7%93%A3%E7%9A%84%E5%BD%B1%E5%93%8D/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2021/11/22/FFT%E8%A1%A5%E9%9B%B6%E5%AF%B9%E6%97%81%E7%93%A3%E7%9A%84%E5%BD%B1%E5%93%8D/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​        本文里面的内容来自网络，感谢原作者，原文地址：<a target="_blank" rel="noopener" href="https://blog.csdn.net/weixin_35841706/article/details/116255216?spm=1001.2101.3001.6650.1&amp;utm_medium=distribute.pc_relevant.none-task-blog-2~default~CTRLIST~default-1.no_search_link&amp;depth_1-utm_source=distribute.pc_relevant.none-task-blog-2~default~CTRLIST~default-1.no_search_link">https://blog.csdn.net/weixin_35841706/article/details/116255216?spm=1001.2101.3001.6650.1&amp;utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-1.no_search_link&amp;depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-1.no_search_link</a></p>
<p>​        7000个原始数据后面补1000个0</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/859207253d858344d1b100d038da18c8.jpg" style="zoom:40%;">

<p>​        做快速傅里叶变换，结果如下：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/94f68f9cc7aa48cc546835a421f3d133.jpg" style="zoom:50%;">

<p>​        <strong>上图中会有一些旁瓣出现，这是因为补零影响了原始信号</strong>，如果，直接采8000个点作为原始数据，那么有：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/f71831ac37b4052563c6e5376ed1b4d3.jpg" style="zoom:50%;">

<p>​        做FFT，结果如下</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/53535b96be6a711993a9a68e25420f6e.jpg" style="zoom:50%;">
      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2021/11/22/FFT%E8%A1%A5%E9%9B%B6%E7%9A%84%E4%BD%9C%E7%94%A8/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2021/11/22/FFT%E8%A1%A5%E9%9B%B6%E7%9A%84%E4%BD%9C%E7%94%A8/" class="post-title-link" itemprop="url">FFT补零的作用</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-11-22 13:35:09" itemprop="dateCreated datePublished" datetime="2021-11-22T13:35:09+08:00">2021-11-22</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E6%9D%82/" itemprop="url" rel="index"><span itemprop="name">杂</span></a>
                </span>
            </span>

          
            <span id="/2021/11/22/FFT%E8%A1%A5%E9%9B%B6%E7%9A%84%E4%BD%9C%E7%94%A8/" class="post-meta-item leancloud_visitors" data-flag-title="FFT补零的作用" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2021/11/22/FFT%E8%A1%A5%E9%9B%B6%E7%9A%84%E4%BD%9C%E7%94%A8/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2021/11/22/FFT%E8%A1%A5%E9%9B%B6%E7%9A%84%E4%BD%9C%E7%94%A8/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​        关于FFT补零的作用主要看了网友的文章，写的比较好，原文链接：<a target="_blank" rel="noopener" href="http://blog.sciencenet.cn/blog-425437-1043431.html">http://blog.sciencenet.cn/blog-425437-1043431.html</a></p>
<p><a target="_blank" rel="noopener" href="https://blog.csdn.net/weixin_35841706/article/details/116255216?spm=1001.2101.3001.6650.1&amp;utm_medium=distribute.pc_relevant.none-task-blog-2~default~CTRLIST~default-1.no_search_link&amp;depth_1-utm_source=distribute.pc_relevant.none-task-blog-2~default~CTRLIST~default-1.no_search_link">https://blog.csdn.net/weixin_35841706/article/details/116255216?spm=1001.2101.3001.6650.1&amp;utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-1.no_search_link&amp;depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-1.no_search_link</a></p>
<h3 id="什么是补零"><a href="#什么是补零" class="headerlink" title="什么是补零"></a>什么是补零</h3><p>​        补零(Zero Padding)就是对变换前的时域或空域信号的尾部添加若干个0，以增加数据长度。下图为含有1.00 MHz 和1.05 MHz 两个频率成分合成的正弦波实信号</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/1950003w2s7j75sgy15ss4.jpg" style="zoom:80%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/195000zmdsllipieuemssu.jpg" style="zoom:80%;">

<p>​        上图中信号长度为1000个样点，采样频率为<em>f</em>s=100 MHz时，信号的实际时长则为10 us。在其尾部添加1000个0，即数据增加到了2000个点（时长为20us）。</p>
<h3 id="波形分辨率和FFT分辨率"><a href="#波形分辨率和FFT分辨率" class="headerlink" title="波形分辨率和FFT分辨率"></a>波形分辨率和FFT分辨率</h3><p>​        波形频率分辨率是指可以被分辨的2个频率的最小间隔，其由原始数据的时间长度决定：Δ<em>Rw</em>= 1/<em>T</em>，其中，<em>T</em>是实际信号的时间长度。</p>
<p>​        FFT分辨率，其由采样频率和参与FFT的数据点数决定，可以定义为：Δ<em>Rf</em>= <em>f</em>s/<em>Nfft</em>，其中，<em>fs</em>为采样频率（the sampling frequency），<em>Nfft</em>为FFT的点数。Δ<em>Rf</em>代表了FFT频率轴上的频率取值的间隔（Spacing）。</p>
<p>​        之所以要区分，就是因为后面要进行“补零”的操作。如果不补零，直接对原始数据做FFT，那么这两种分辨率是类似的。例如上面，有：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20211122144913.png" style="zoom:50%;">

<p>​        值得注意的是，可能有很好的FFT分辨率，但却不一定能够很好的把2个频率成分简单的分开。同样，可能有很高的波形分辨率，但波形的能量峰值会通过整个频谱而分散开（这是因为FFT的频率泄漏现象）。</p>
<h3 id="实例分析"><a href="#实例分析" class="headerlink" title="实例分析"></a>实例分析</h3><p><strong>1.时域信号1000个点采样，做相同样点数的FFT</strong></p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/195312i0ddrratq0xtnvn0.jpg" style="zoom:67%;">

<p>​        可以发现，频谱点稀疏，在1MHz附近根本无法将1 MHz和1.05 MHz的两个频率分开。</p>
<p><strong>2.时域信号1000个点采样，后端补6000个零，做7000点数的FFT</strong></p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/19543246d6wwdogzm99jwq.jpg" style="zoom:67%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/1954322pwt54p93evzvtvv.jpg" style="zoom:67%;">

<p>可以发现，频谱点密集了太多，但是在1MHz附近依然无法将1MHz和1.05MHz的两个频率分量分开。这是因为波形分辨率<strong>只与原始数据的时长T</strong>相关，而与参与FFT的数据点数无关。虽然补补了很多零，但波形分辨率依然为1 /10μs= 100 kHz，该分辨率大于1MHz和1.05MHz这两个频率之间的距离50 kHz。</p>
<p>​        而“时域补零等于频域插值”，补零操作增加了频域的插值点数，让频域曲线看起来更加平滑，也就是增加了FFT频率分辨率。</p>
<p>​        关于把两个频率接近的波形区分开来，也可以看下面这个截图：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20211122163925.png" style="zoom:70%;">

<p><strong>3.时域信号7000个点采样，做7000点数的FFT</strong></p>
<p>​        根据上面的分析可知，在采样频率不变的情况下，要想将1MHz和1.05MHz这两个频率成分分析出来，光靠“补零”是不够的，<strong>必须要改变波形分辨率，也就是要延长原始数据的时长</strong>。现在以相同的采样频率对信号采7000个点作为原始信号：</p>
<p>​        因此，我们直接采集波形的7000点作为输入信号，取代补零（Zero Padding）方式到 70us (7000 点) 。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/1956551mevdmemqoim1fev.jpg" style="zoom:67%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/195655gmzuxgqg6m6xyz5q.jpg" style="zoom:67%;">

<p>​        因为此时的波形分辨率为：1 /70μs≈14kHz，小于1MHz和1.05MHz这两个频率之中的距离50 kHz，所以可以看到有两个明显的突起。但是在1.05MHz对应的幅值周围的点上却都有不小的幅值，原因就是1.05 MHz处并没有FFT点的分布，原因是此处的能量被多个FFT点分散（泄露）了。因为采样频率是100 MHz，FFT点数为7000。频谱图中，点与点之间的间隔是14.28 kHz。1 MHz频率刚好为频率间隔的整数陪，而1.05 MHz 却不是。距1.05 MHz最近的整数倍频率为1.043 MHz 和1.057 MHz, 因此，能量被这2个FFT单元所分散。</p>
<p><strong>4.时域信号7000个点采样，后端补1000个零，做8000点数的FFT</strong></p>
<p>​        为了解决这个问题，我们可以合理选择FFT的点数，以便这两个点能在频率轴上成为独立分开的点。由于，我们并不需要更好的波形频率分辨率，仅采用时域数据的零填充方式来调整FFT数据点的频率间隔。</p>
<p>​        给时域信号增加1000零值(10 us)，使得频率间隔为12.5 kHz，这样，满足了1 MHz and 1.05 MHz两个频率都是这个间隔的整数倍。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/195843v40p5fizttv54igf.jpg" style="zoom:67%;">
      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2021/11/21/%E6%AF%AB%E7%B1%B3%E6%B3%A2%E9%9B%B7%E8%BE%BE%E6%B5%8B%E8%B7%9D%E5%8E%9F%E7%90%86/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2021/11/21/%E6%AF%AB%E7%B1%B3%E6%B3%A2%E9%9B%B7%E8%BE%BE%E6%B5%8B%E8%B7%9D%E5%8E%9F%E7%90%86/" class="post-title-link" itemprop="url">毫米波雷达测距原理</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-11-21 10:34:54" itemprop="dateCreated datePublished" datetime="2021-11-21T10:34:54+08:00">2021-11-21</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E9%9B%B7%E8%BE%BE/" itemprop="url" rel="index"><span itemprop="name">雷达</span></a>
                </span>
            </span>

          
            <span id="/2021/11/21/%E6%AF%AB%E7%B1%B3%E6%B3%A2%E9%9B%B7%E8%BE%BE%E6%B5%8B%E8%B7%9D%E5%8E%9F%E7%90%86/" class="post-meta-item leancloud_visitors" data-flag-title="毫米波雷达测距原理" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2021/11/21/%E6%AF%AB%E7%B1%B3%E6%B3%A2%E9%9B%B7%E8%BE%BE%E6%B5%8B%E8%B7%9D%E5%8E%9F%E7%90%86/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2021/11/21/%E6%AF%AB%E7%B1%B3%E6%B3%A2%E9%9B%B7%E8%BE%BE%E6%B5%8B%E8%B7%9D%E5%8E%9F%E7%90%86/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​        关于毫米波雷达测距原理，参考了网上很多其他文章，这边粘贴了原文的链接，对他们表示感谢。</p>
<p><a target="_blank" rel="noopener" href="https://wenku.baidu.com/view/45d975c7cd84b9d528ea81c758f5f61fb636281f.html">https://wenku.baidu.com/view/45d975c7cd84b9d528ea81c758f5f61fb636281f.html</a></p>
<p><a target="_blank" rel="noopener" href="https://blog.csdn.net/wss794/article/details/105138817/">https://blog.csdn.net/wss794/article/details/105138817/</a></p>
<p><a target="_blank" rel="noopener" href="https://blog.csdn.net/sally789/article/details/120312070">https://blog.csdn.net/sally789/article/details/120312070</a></p>
<h3 id="测距基本原理"><a href="#测距基本原理" class="headerlink" title="测距基本原理"></a>测距基本原理</h3><p>1.发射波TX为高频连续波，其频率随时间按一定规律变化。</p>
<p>2.发射波TX遇到物体后反射，接收器接收到反射波RX。</p>
<p>3.信号的发射到接收，产生一定的时间间隔t。由于这个时间间隔，得到频率差值信号IF signal。<strong>IF表示中频</strong>。</p>
<p>4.对频率差值信号，进行FFT变换，得到对应的频谱。频谱的峰值处对应的频率f和距离d具有对应关系，进而得到距离d。</p>
<p>5.测距分辨率的分析。</p>
<h3 id="什么是chirp"><a href="#什么是chirp" class="headerlink" title="什么是chirp"></a>什么是chirp</h3><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202111211047020.png" style="zoom:67%;">

<p>上图是频率fc开始的线性调频脉冲，4GHZ的带宽，最终以81GHZ的频率结束。</p>
<p>线性调频脉冲的斜率S：线性调频脉冲上升的速率。</p>
<p><strong>带宽B和斜率S是系统性能的重要参数。</strong></p>
<h3 id="中频信号IF"><a href="#中频信号IF" class="headerlink" title="中频信号IF"></a>中频信号IF</h3><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202111211052646.png" style="zoom:50%;">

<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202111211056304.png"></p>
<h3 id="测距分辨率："><a href="#测距分辨率：" class="headerlink" title="测距分辨率："></a>测距分辨率：</h3><p>​        当雷达前面有两个物体，当他们靠的很近的时候，如何在频谱上把他们区分开来。为了使这两个频率在IF频谱中显示为不同的峰值，<strong>在采样周期T 内，要满足 Δf &gt;= 1/T</strong>。</p>
<p>​        其中<strong>Δf &gt;= 1/T</strong>的推导如下所示：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20211122190410.png" style="zoom:67%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20211122190640.png" style="zoom:50%;">

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2021/11/20/nRF%20connect%20for%20Desktop%E6%97%A0%E6%B3%95%E4%B8%8B%E8%BD%BDAPP/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2021/11/20/nRF%20connect%20for%20Desktop%E6%97%A0%E6%B3%95%E4%B8%8B%E8%BD%BDAPP/" class="post-title-link" itemprop="url">nRF connect for Desktop无法下载APP</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-11-20 13:45:58" itemprop="dateCreated datePublished" datetime="2021-11-20T13:45:58+08:00">2021-11-20</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E5%B7%A5%E5%85%B7/" itemprop="url" rel="index"><span itemprop="name">工具</span></a>
                </span>
            </span>

          
            <span id="/2021/11/20/nRF%20connect%20for%20Desktop%E6%97%A0%E6%B3%95%E4%B8%8B%E8%BD%BDAPP/" class="post-meta-item leancloud_visitors" data-flag-title="nRF connect for Desktop无法下载APP" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2021/11/20/nRF%20connect%20for%20Desktop%E6%97%A0%E6%B3%95%E4%B8%8B%E8%BD%BDAPP/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2021/11/20/nRF%20connect%20for%20Desktop%E6%97%A0%E6%B3%95%E4%B8%8B%E8%BD%BDAPP/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​        最近使用Nordic发布的二代功耗测量套件Power Profiler Kit II测量电流，官方称它的分辨率100nA，范围200nA到1A。使用的时候会配套一个上位机，但是把上位机安装好之后，尝试下载使用它的power测量工具，总是报错误。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/打开报的错误.png" style="zoom:67%;">

<p>按照网友给的方法可以解决问题，原文地址：<a target="_blank" rel="noopener" href="https://blog.csdn.net/MEMORY_2016/article/details/117512713">https://blog.csdn.net/MEMORY_2016/article/details/117512713</a></p>
<p>​        详解：刚进入nRF connect 的时候，软件会检查apps.json来更新应用列表，但是总是因为网络原因报错。既然报错是apps.json无法更新，那就可以直接去Nordic 的github 仓库，下载相应的apps.json进行替换。</p>
<p>​        地址:<a target="_blank" rel="noopener" href="https://github.com/NordicSemiconductor/pc-nrfconnect-launcher/blob/master/apps.json">https://github.com/NordicSemiconductor/pc-nrfconnect-launcher/blob/master/apps.json</a></p>
<p>​        直接复制文件内容，粘贴保存到本地文件apps.json。本地apps.json文件路径：C:\Users\xxx\.nrfconnect-apps，其中xxx是自己的用户名。替换之后重新打开nRF connnect，就可以看到应用列表更新成功。</p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  


  
  <nav class="pagination">
    <a class="extend prev" rel="prev" href="/page/18/"><i class="fa fa-angle-left" aria-label="上一页"></i></a><a class="page-number" href="/">1</a><span class="space">&hellip;</span><a class="page-number" href="/page/18/">18</a><span class="page-number current">19</span><a class="page-number" href="/page/20/">20</a><span class="space">&hellip;</span><a class="page-number" href="/page/29/">29</a><a class="extend next" rel="next" href="/page/20/"><i class="fa fa-angle-right" aria-label="下一页"></i></a>
  </nav>



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">xudonglei</p>
  <div class="site-description" itemprop="description">搬砖 嵌入式</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">283</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">19</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">67</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2024</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">xudonglei</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://muse.theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Muse</a> 强力驱动
  </div>

        








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/muse.js"></script>


<script src="/js/next-boot.js"></script>




  




  
<script src="/js/local-search.js"></script>













  

  


<script>
NexT.utils.loadComments(document.querySelector('#valine-comments'), () => {
  NexT.utils.getScript('//unpkg.com/valine/dist/Valine.min.js', () => {
    var GUEST = ['nick', 'mail', 'link'];
    var guest = 'nick,mail,link';
    guest = guest.split(',').filter(item => {
      return GUEST.includes(item);
    });
    new Valine({
      el         : '#valine-comments',
      verify     : false,
      notify     : false,
      appId      : 'BT0Qw9HcTpPv1a6cT1iDBXKz-gzGzoHsz',
      appKey     : 'LMCMh8v02JTMFAwKNRcgoizI',
      placeholder: "Just go go",
      avatar     : 'mm',
      meta       : guest,
      pageSize   : '10' || 10,
      visitor    : true,
      lang       : 'zh-CN' || 'zh-cn',
      path       : location.pathname,
      recordIP   : false,
      serverURLs : ''
    });
  }, window.Valine);
});
</script>

</body>
</html>
